<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="/zero/resources/dijit/themes/tundra/tundra.css" type="text/css" rel="stylesheet" />
<link href="/zero/resources/styles/standard.css" media="screen" type="text/css" rel="stylesheet" />
<link href="/zero/resources/images/favicon.ico" rel="SHORTCUT ICON" />
<script type="text/javascript">
	var djConfig = {
		parseOnLoad : false,
		isDebug : false,
		locale : 'zh'
	};
</script>
<script type="text/javascript" src="/zero/resources/dojo/dojo.js"></script>
<script type="text/javascript" src="/zero/resources/spring/Spring.js"></script>
<script type="text/javascript" src="/zero/resources/spring/Spring-Dojo.js"></script>
<script type="text/javascript" language="JavaScript">
	dojo.require("dojo.parser");
</script>

</head>
<body>

	<script type="text/javascript">
		dojo.require('dijit.TitlePane');
	</script>
    
	<spring:message code="process_definition" htmlEscape="false" javaScriptEscape="true" var="panel_title"/>
	
	<div id="_title_fc_com_ibm_zero_domain_task_id">
		<script type="text/javascript">
			Spring.addDecoration(new Spring.ElementDecoration({
				elementId : '_title_fc_com_ibm_zero_domain_task_id',
				widgetType : 'dijit.TitlePane',
				widgetAttrs : {
					title : '${panel_title}',
					open : true
				}
			}));
		</script>
		
	<label>
		<spring:message code="process_name" htmlEscape="false" />
	</label>
	<div>
		<c:out value="${process.name }" />
	</div>
	<br>

	<label><spring:message code="process_version" htmlEscape="false" /></label>
	<div>
		<c:out value="${process.version }" />
	</div>
	<br>

	<label><spring:message code="process_deploy_time" htmlEscape="false" /></label>
	<div>
		<c:out value="${deployment.deploymentTime }" />
	</div>
	<br>

	<h3><spring:message code="process.header.diagram" htmlEscape="false" /></h3>
	<br>
	<div>
		<spring:url value="/process/${process.id }" var="image_url">
			<spring:param name="processImage" />
		</spring:url>
		<a href="${image_url }" target="_blank">
		<img src="${image_url }"></a>
	</div>
	<br>

<c:if test="${param.startForm==null }">

	<label></label>
	<div>
		<c:url value="/process/${process.id }" var="action_url" >
			<c:param name="start"></c:param>
		</c:url>
		<form:form action="${action_url }" method="POST">
			<spring:message code="process.start" var="start_label" htmlEscape="false" />
			<input type="submit" value="${fn:escapeXml(start_label)}"  alt="${fn:escapeXml(start_label)}" title="${fn:escapeXml(start_label)}" />
		</form:form>
	</div>
</c:if>

<c:if test="${param.startForm!=null }">

	<c:url value="/process/${process.id }" var="action_url">
		<c:param name="startFormSubmit"></c:param>
	</c:url>

	<form:form modelAttribute="processStartForm" action="${action_url }" method="POST">

		<label><spring:message code="process.instance.businesskey" htmlEscape="false" /></label>
		<div>
			<form:input path="businessKey" />
		</div>
		<br>

		<c:forEach items="${startFormProperties }" var="formProperty">

			<label><c:out value="${formProperty.name }" /></label>


			<c:choose>
				<c:when test="${formProperty.required}">
					<spring:message code="field_required" var="field_required" htmlEscape="false" />
					<spring:message argumentSeparator="," arguments="${formProperty.name },(${field_required})" code="field_simple_validation" var="field_validation" htmlEscape="false" />
				</c:when>
				<c:otherwise>
					<spring:message argumentSeparator="," arguments="${formProperty.name }, " code="field_simple_validation" var="field_validation" htmlEscape="false" />
				</c:otherwise>
			</c:choose>

			<c:set var="sec_field_validation">
				<spring:escapeBody javaScriptEscape="true">${field_validation}</spring:escapeBody>
			</c:set>

			<c:choose>
				<c:when test="${!formProperty.writable || !formProperty.readable}">
				</c:when>

				<c:when test="${formProperty.type.name=='string' || formProperty.type.name=='long' }">
					<div>
						<form:input path="properties[${formProperty.id }]" />
						<script type="text/javascript">
							Spring.addDecoration(new Spring.ElementDecoration({
								elementId : "properties${formProperty.id }",
								widgetType : "dijit.form.ValidationTextBox",
								widgetAttrs : {
									promptMessage : "${sec_field_validation}",
									required : true
								}
							}));
						</script>
					</div>
				</c:when>
				
				<c:when test="${formProperty.type.name=='enum' }">
					<div>
						<form:select path="properties[${formProperty.id }]">
							<form:option value=""></form:option>
							<form:options items="${formProperty.type.getInformation('values') }" />
						</form:select>
					</div>
				</c:when>
			</c:choose>
			
			<br>
					
		</c:forEach>

		<label></label>
		<div>
			<spring:message code="process.start" var="start_label" htmlEscape="false" />
			<input type="submit" value="${fn:escapeXml(start_label)}"  alt="${fn:escapeXml(start_label)}" title="${fn:escapeXml(start_label)}" />
		</div>
		<br>
	</form:form>
</c:if>

	</div>
	
</body>
</html>